<template>
<span :class="wrapper_name">
  <button v-if="col.btns.ADDTR" class="ui button primary mini" @click.stop.prevent="ADDTR(col.val)" title="BC端上架">
    {{col.btns.ADDTR}}
  </button>
</span>
</template>
<script type="text/ecmascript-6">
import tool from 'src/util/tool';
import util from '_util/index';
import logic from '_logic';
export default {
    data() {
        return {}
    },
    methods: {
		ADDTR(id){
			let _this = this;
			//warehouse_id
			util.http.getDataCom(_this, '/index/Get/get_whuse', {
				warehouse_id:logic.detail.getDetail(_this, _this._id,'warehouse_id').val
			},(rs) => {
				let ids = [];
				if(Array.isArray(rs)){
					rs.forEach(item=>{
						ids.push(item.hotel_id)
					})
				}
				ids = ids.toString();
				if(ids.length>0){
					util.store.push(_this, 'set_in_modal','in_modal',false,true,'global');
					util.store.get(_this, 'eventVue').$emit('showPopCom', {
						_this: this,
						id: id,
						data: {
							fn: {
								sure: function(data) {
									let param = {
										hotel_id: data.id,
										warehouse_top_product_ids:id
									};
									util.http.SR(_this, '/index/Product/addStock', param, '添加成功', (rs) => {
										logic.list.refreshListData(_this);
									});
								}
							},
							field: {
								bindModel: 1,
								bind_type: 0,
								title: '商品绑定场景',
								name: 'id',
								bind_name_field: 'name',
								bind_param:`ids=${ids}&is_search=1`,
								search_field:'name'
							}
						},
						hide_in_model:true,
						name: 'Jbind'
					});
				}else {
					util.showMsg(_this, 'info', '该仓库未绑定场景，请先到场景列表绑定。');
				}



			});

		},
    },
    computed: {
        ctl() {
            return this.$route.query.ctl;
        },
        is_admin() {
            return util.is_admin(this);
        },
    },
    watch: {},

    props: ['col', '_id', 'detail_info', 'wrapper_name'],
    created() {},
}
</script>
<style rel="stylesheet/less" lang="less">
</style>
